#!/bin/bash
# OpenCV-Rust 项目环境设置脚本 (Bash 版本)
# 在项目目录中运行: source ./setup_opencv_env.sh 或 . ./setup_opencv_env.sh

echo -e "\033[36m设置 OpenCV-Rust 环境...\033[0m"

# 设置环境变量
export PKG_CONFIG_PATH="/Users/licheng/Work/openmmlab_wl/opencv/build_arm64/install_arm64/lib/pkgconfig:$PKG_CONFIG_PATH"
export OPENCV_LIB_PATH="/Users/licheng/Work/openmmlab_wl/opencv/build_arm64/install_arm64/lib"
export OPENCV_INCLUDE_PATH="/Users/licheng/Work/openmmlab_wl/opencv/build_arm64/install_arm64/include"
export OpenCV_DIR="/Users/licheng/Work/openmmlab_wl/opencv/build_arm64/install_arm64"

echo -e "\033[32m环境变量设置完成!\033[0m"
echo -e "\033[33mPKG_CONFIG_PATH: $PKG_CONFIG_PATH\033[0m"

# 检查 libclang.dylib 是否存在
if [ -L "/usr/local/lib/libclang.dylib" ]; then
    echo -e "\033[32m✓ libclang.dylib 符号链接存在\033[0m"
else
    echo -e "\033[31m⚠ libclang.dylib 符号链接不存在，需要重新创建\033[0m"
    echo -e "\033[33m运行: sudo ln -sf /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib /usr/local/lib/libclang.dylib\033[0m"
fi

# 检查 OpenCV 安装目录是否存在
if [ -d "$OpenCV_DIR" ]; then
    echo -e "\033[32m✓ OpenCV 安装目录存在\033[0m"
else
    echo -e "\033[31m⚠ OpenCV 安装目录不存在: $OpenCV_DIR\033[0m"
fi

echo -e "\033[32m现在可以运行 'cargo build' 了!\033[0m" 